home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
tool6v12
/
demolzh.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-07-01
|
2KB
|
84 lines
{$A+,B-,D+,E+,F-,I-,L+,N+,O-,R-,S-,V-}
{$M 16384,0,655360}
Program DemoLZH;
Uses
LZH;
Var
Infile,
Outfile : File;
Option : String[1];
Procedure ShowError(Message: String);
Begin
Writeln(Message);
Halt(1)
end;
Procedure ReadNextBlock; far;
Begin
BlockRead(Infile,Inbuf.BuffData^,InBuf.BuffSize,Inend);
If IOResult > 0 then
ShowError('Error reading input file');
end;
Procedure WriteNextBlock; far;
Var
BytesWritten: Word;
Begin
BlockWrite(Outfile,Outbuf.BuffData^,Outptr,BytesWritten);
If (IOResult > 0) or (BytesWritten < Outptr) then
ShowError('Error writing output file');
end;
Procedure OpenInput(FileName: String);
Begin
Assign(Infile,FileName);
Reset(Infile,1);
If IOResult > 0 then
ShowError('Can''t open input file');
end;
Procedure OpenOutput(FileName: String);
Begin
Assign(Outfile,FileName);
Rewrite(Outfile,1);
If IOResult > 0 then
ShowError('Can''t open output file');
end;
Begin
If ParamCount <> 3 then
ShowError('Usage: demolzh c(compression) | d(uncompression) infile outfile');
InitLZHBuffers(10240);
OpenInput(ParamStr(2));
OpenOutput(ParamStr(3));
Option := ParamStr(1);
Case UpCase(Option[1]) of
'C': Encode(ReadNextBlock,WriteNextBlock,FileSize(Infile));
'D': Decode(ReadNextBlock,WriteNextBlock);
else
ShowError('Use [D] for Decompression or [C] for Compression')
end;
Close(Infile);
If IOResult > 0 then
ShowError('Error closing input file');
Close(Outfile);
If IOResult > 0 then
ShowError('Error closing output file');
FreeLZHBuffers;
end.